//
//  LFCouponTopView.m
//  LoveFruit
//
//  Created by libbbb on 16/9/27.
//  Copyright © 2016年 张令林. All rights reserved.
//

#import "LFCouponTopView.h"

@interface LFCouponTopView ()

@property(weak, nonatomic)UITextField * textV2l;

@end

@implementation LFCouponTopView


- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
        
    }
    return self;
}
- (void)setupUI{
    
    self.backgroundColor = [UIColor whiteColor];
    
    UITextField *numTextField = [[UITextField alloc]init];
    _textV2l = numTextField;
    numTextField.placeholder = @"请输入优惠券号码";
    numTextField.borderStyle = UITextBorderStyleRoundedRect;
    [self addSubview:numTextField];
    
    [numTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@6);
        make.left.equalTo(@12);
        make.height.equalTo(@29);
        make.width.equalTo(@270);
        
    }];
    
    UIButton *okBtn = [[UIButton alloc]init];
    okBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [okBtn setBackgroundImage:[UIImage imageNamed:@"v2_coupon_verify_normal"] forState:UIControlStateNormal];
    [self addSubview:okBtn];
    
    [okBtn setTitle:@"绑定" forState:UIControlStateNormal];
    [okBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(numTextField);
        make.left.equalTo(numTextField.mas_right).offset(10);
        make.right.equalTo(self).offset(-13);
        make.height.equalTo(@29);
    }];
    [okBtn addTarget:self action:@selector(okBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)okBtnClick:(UIButton *)sender{
    
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"输入正确的优惠券号码" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
    
    alertView.frame = CGRectMake(100, 100, 100, 100);
    
    [alertView show];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [_textV2l resignFirstResponder];
    //    self.na
    
}

@end
